package com.dkd.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dkd.common.annotation.Log;
import com.dkd.common.core.controller.BaseController;
import com.dkd.common.core.domain.AjaxResult;
import com.dkd.common.enums.BusinessType;
import com.dkd.manage.domain.Drivers;
import com.dkd.manage.service.IDriversService;
import com.dkd.common.utils.poi.ExcelUtil;
import com.dkd.common.core.page.TableDataInfo;

/**
 * 驾驶员资料管理Controller
 * 
 * @author yuwensheng
 * @date 2024-09-16
 */
@RestController
@RequestMapping("/manage/drivers")
public class DriversController extends BaseController
{
    @Autowired
    private IDriversService driversService;

    /**
     * 查询驾驶员资料管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:drivers:list')")
    @GetMapping("/list")
    public TableDataInfo list(Drivers drivers)
    {
        startPage();
        List<Drivers> list = driversService.selectDriversList(drivers);
        return getDataTable(list);
    }

    /**
     * 导出驾驶员资料管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:drivers:export')")
    @Log(title = "驾驶员资料管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Drivers drivers)
    {
        List<Drivers> list = driversService.selectDriversList(drivers);
        ExcelUtil<Drivers> util = new ExcelUtil<Drivers>(Drivers.class);
        util.exportExcel(response, list, "驾驶员资料管理数据");
    }

    /**
     * 获取驾驶员资料管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:drivers:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(driversService.selectDriversById(id));
    }

    /**
     * 新增驾驶员资料管理
     */
    @PreAuthorize("@ss.hasPermi('manage:drivers:add')")
    @Log(title = "驾驶员资料管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Drivers drivers)
    {
        return toAjax(driversService.insertDrivers(drivers));
    }

    /**
     * 修改驾驶员资料管理
     */
    @PreAuthorize("@ss.hasPermi('manage:drivers:edit')")
    @Log(title = "驾驶员资料管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Drivers drivers)
    {
        return toAjax(driversService.updateDrivers(drivers));
    }

    /**
     * 删除驾驶员资料管理
     */
    @PreAuthorize("@ss.hasPermi('manage:drivers:remove')")
    @Log(title = "驾驶员资料管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(driversService.deleteDriversByIds(ids));
    }
}
